#include "headers/Tigerengine.h"



// ----------------------------------------------
// Init()
//
//	Setup the list of devices to monitor for input.
// -----------------------------------------------
int CInputManager::Init(int flags)
{
	RAWINPUTDEVICE	rid[3];

	memset(rid, 0, sizeof(RAWINPUTDEVICE) * 3);
	
	// Setup Keyboard
	rid[0].usUsagePage = 0x01;
	rid[0].usUsage = 0x06;
	rid[0].dwFlags = RIDEV_NOLEGACY;
	rid[0].hwndTarget = 0;

	// Setup Mouse
	rid[1].usUsagePage = 0x01;
	rid[1].usUsage = 0x02;
	rid[1].dwFlags = 0;
	rid[1].hwndTarget = 0;

	// Setup Gamepad
	rid[2].usUsagePage = 0x01;
	rid[2].usUsage = 0x05;
	rid[2].dwFlags = 0;
	rid[2].hwndTarget = 0;

	// Now register this with Windows
	if(RegisterRawInputDevices(rid, 3, sizeof(rid[0])) == FALSE)
	{
		return RET_ERR_REGINPUT;
	}

	return RET_SUCCESS;
} // void CInput::Init(void)


void CInputManager::OnKeyPress(USHORT key)
{
	m_KeyState[key] = true;
}

void CInputManager::OnKeyRelease(USHORT key)
{
	m_KeyState[key] = false;
}

bool CInputManager::GetKeyStatus(USHORT key)
{
	return m_KeyState[key];
}

void CInputManager::OnGamepadPress(BYTE button)
{
	//m_GamepadState[button] = true;
}


CInputManager::CInputManager()
{
	ZeroMemory(&m_KeyState[0], sizeof(m_KeyState));

}